<template>
	<el-dialog title="打卡对话框" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :disabled="mode=='show'" ref="dialogForm" label-width="100px" label-position="left">
				<el-input v-model="form.remark" maxlength="150" clearable type="textarea" placeholder="打卡说明"></el-input>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	components: {},
	emits: ['success', 'closed'],
	data() {
		return {
			visible: false,
			isSaveing: false,
			//表单数据
			form: {
				configId: this.$TOOL.data.get("USER_INFO").attend,
				address: "",
				status: '',
				longitude: '',
				latitude: '',
				source: 'pc',
				remark: ''
			},
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this
		},
		//表单提交方法
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.office.attend.insertAttend.post(this.form);
					this.isSaveing = false;
					if (res.code == 200) {
						this.$emit('success',this.form.status)
						this.visible = false;
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		setData(data) {
			this.form.status = data.status
		},
	}
}
</script>

<style>
</style>
